#pragma once
#include<Arduino.h>

namespace ganix
{
    namespace pwm
    {
        int freq = 1024 * 32;
        int range = freq;
        
        void set_rate(int pin, float rate) {
            analogWrite(pin, (int) (rate * range));
        }

        void init(int _freq = freq, int _range = range) {
            analogWriteRange(range = _range);
            analogWriteFreq(freq = freq);
        }
    } // namespace pwm
    
} // namespace ganix
